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

#include <G4H1Messenger.hh>

+ Inheritance diagram for G4H1Messenger:

Public Member Functions

 G4H1Messenger (G4VAnalysisManager *manager)
 
virtual ~G4H1Messenger ()
 
virtual void SetNewValue (G4UIcommand *command, G4String value) final
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 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 (G4String s)
 
G4long StoL (G4String s)
 
G4double StoD (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 49 of file G4H1Messenger.hh.

Constructor & Destructor Documentation

◆ G4H1Messenger()

G4H1Messenger::G4H1Messenger ( G4VAnalysisManager manager)
explicit

Definition at line 49 of file G4H1Messenger.cc.

50 : G4UImessenger(),
51 fManager(manager),
52 fHelper(nullptr),
53 fDirectory(nullptr),
54 fCreateH1Cmd(nullptr),
55 fSetH1Cmd(nullptr),
56 fSetH1TitleCmd(nullptr),
57 fSetH1XAxisCmd(nullptr),
58 fSetH1YAxisCmd(nullptr)
59{
60 fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("h1");
61
62 fDirectory = fHelper->CreateHnDirectory();
63
64 CreateH1Cmd();
65
66 SetH1Cmd();
67 fSetH1XCmd = fHelper->CreateSetBinsCommand("x", this);
68
69
70 fSetH1TitleCmd = fHelper->CreateSetTitleCommand(this);
71 fSetH1XAxisCmd = fHelper->CreateSetAxisCommand("x", this);
72 fSetH1YAxisCmd = fHelper->CreateSetAxisCommand("y", this);
73 fSetH1XAxisLogCmd = fHelper->CreateSetAxisLogCommand("x", this);
74 fSetH1YAxisLogCmd = fHelper->CreateSetAxisLogCommand("y", this);
75}

◆ ~G4H1Messenger()

G4H1Messenger::~G4H1Messenger ( )
virtual

Definition at line 78 of file G4H1Messenger.cc.

79{}

Member Function Documentation

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 199 of file G4H1Messenger.cc.

200{
201 // tokenize parameters in a vector
202 std::vector<G4String> parameters;
203 G4Analysis::Tokenize(newValues, parameters);
204 // check consistency
205 if ( parameters.size() != command->GetParameterEntries() ) {
206 // Should never happen but let's check anyway for consistency
207 fHelper->WarnAboutParameters(command, parameters.size());
208 return;
209 }
210
211 if ( command == fCreateH1Cmd.get() ) {
212 auto counter = 0;
213 auto name = parameters[counter++];
214 auto title = parameters[counter++];
216 fHelper->GetBinData(xdata, parameters, counter);
217 auto unit = GetUnitValue(xdata.fSunit);
218 fManager->CreateH1(name, title,
219 xdata.fNbins, xdata.fVmin*unit, xdata.fVmax*unit,
220 xdata.fSunit, xdata.fSfcn, xdata.fSbinScheme);
221 }
222 else if ( command == fSetH1Cmd.get() ) {
223 auto counter = 0;
224 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
226 fHelper->GetBinData(xdata, parameters, counter);
227 auto unit = GetUnitValue(xdata.fSunit);
228 fManager->SetH1(id,
229 xdata.fNbins, xdata.fVmin*unit, xdata.fVmax*unit,
230 xdata.fSunit, xdata.fSfcn, xdata.fSbinScheme);
231 }
232 else if ( command == fSetH1XCmd.get() ) {
233 auto counter = 0;
234 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
236 fHelper->GetBinData(xdata, parameters, counter);
237 auto unit = GetUnitValue(xdata.fSunit);
238 fManager->SetH1(id,
239 xdata.fNbins, xdata.fVmin*unit, xdata.fVmax*unit,
240 xdata.fSunit, xdata.fSfcn, xdata.fSbinScheme);
241 }
242 else if ( command == fSetH1TitleCmd.get() ) {
243 auto counter = 0;
244 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
245 auto title = parameters[counter++];
246 fManager->SetH1Title(id, title);
247 }
248 else if ( command == fSetH1XAxisCmd.get() ) {
249 auto counter = 0;
250 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
251 auto xaxis = parameters[counter++];
252 fManager->SetH1XAxisTitle(id, xaxis);
253 }
254 else if ( command == fSetH1YAxisCmd.get() ) {
255 auto counter = 0;
256 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
257 auto yaxis = parameters[counter++];
258 fManager->SetH1YAxisTitle(id, yaxis);
259 }
260 else if ( command == fSetH1XAxisLogCmd.get() ) {
261 auto counter = 0;
262 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
263 auto xaxisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
264 fManager->SetH1XAxisIsLog(id, xaxisLog);
265 }
266 else if ( command == fSetH1YAxisLogCmd.get() ) {
267 auto counter = 0;
268 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
269 auto yaxisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
270 fManager->SetH1YAxisIsLog(id, yaxisLog);
271 }
272}
std::size_t GetParameterEntries() const
Definition: G4UIcommand.hh:138
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:543
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:530
G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
G4bool SetH1YAxisIsLog(G4int id, G4bool isLog)
G4bool SetH1Title(G4int id, const G4String &title)
G4bool SetH1XAxisTitle(G4int id, const G4String &title)
G4bool SetH1XAxisIsLog(G4int id, G4bool isLog)
G4bool SetH1(G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
G4bool SetH1YAxisTitle(G4int id, const G4String &title)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4double GetUnitValue(const G4String &unit)
const char * name(G4int ptype)

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