Geant4  10.02.p03
G4H1Messenger Class Reference

#include <G4H1Messenger.hh>

Inheritance diagram for G4H1Messenger:
Collaboration 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)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Private Member Functions

void CreateH1Cmd ()
 
void SetH1Cmd ()
 

Private Attributes

G4VAnalysisManagerfManager
 Associated class. More...
 
std::unique_ptr< G4AnalysisMessengerHelperfHelper
 
std::unique_ptr< G4UIdirectoryfDirectory
 
std::unique_ptr< G4UIcommandfCreateH1Cmd
 
std::unique_ptr< G4UIcommandfSetH1Cmd
 
std::unique_ptr< G4UIcommandfSetH1XCmd
 
std::unique_ptr< G4UIcommandfSetH1TitleCmd
 
std::unique_ptr< G4UIcommandfSetH1XAxisCmd
 
std::unique_ptr< G4UIcommandfSetH1YAxisCmd
 

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)
 
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
 
G4String baseDirName
 
G4bool commandsShouldBeInMaster
 

Detailed Description

Definition at line 50 of file G4H1Messenger.hh.

Constructor & Destructor Documentation

◆ G4H1Messenger()

G4H1Messenger::G4H1Messenger ( G4VAnalysisManager manager)
explicit

Definition at line 50 of file G4H1Messenger.cc.

51  : G4UImessenger(),
52  fManager(manager),
53  fHelper(nullptr),
54  fDirectory(nullptr),
55  fCreateH1Cmd(nullptr),
56  fSetH1Cmd(nullptr),
57  fSetH1TitleCmd(nullptr),
58  fSetH1XAxisCmd(nullptr),
59  fSetH1YAxisCmd(nullptr)
60 {
61  fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("h1");
62 
63  fDirectory = fHelper->CreateHnDirectory();
64 
65  CreateH1Cmd();
66 
67  SetH1Cmd();
68  fSetH1XCmd = fHelper->CreateSetBinsCommand("x", this);
69 
70 
71  fSetH1TitleCmd = fHelper->CreateSetTitleCommand(this);
72  fSetH1XAxisCmd = fHelper->CreateSetAxisCommand("x", this);
73  fSetH1YAxisCmd = fHelper->CreateSetAxisCommand("y", this);
74 }
std::unique_ptr< G4UIcommand > fSetH1XCmd
std::unique_ptr< G4UIcommand > fSetH1TitleCmd
std::unique_ptr< G4UIcommand > fSetH1XAxisCmd
void CreateH1Cmd()
std::unique_ptr< G4UIcommand > fSetH1Cmd
std::unique_ptr< G4UIdirectory > fDirectory
std::unique_ptr< G4UIcommand > fSetH1YAxisCmd
std::unique_ptr< G4UIcommand > fCreateH1Cmd
std::unique_ptr< G4AnalysisMessengerHelper > fHelper
G4VAnalysisManager * fManager
Associated class.
Here is the call graph for this function:

◆ ~G4H1Messenger()

G4H1Messenger::~G4H1Messenger ( )
virtual

Definition at line 77 of file G4H1Messenger.cc.

78 {}

Member Function Documentation

◆ CreateH1Cmd()

void G4H1Messenger::CreateH1Cmd ( )
private

Definition at line 85 of file G4H1Messenger.cc.

86 {
87  auto h1Name = new G4UIparameter("name", 's', false);
88  h1Name->SetGuidance("Histogram name (label)");
89 
90  auto h1Title = new G4UIparameter("title", 's', false);
91  h1Title->SetGuidance("Histogram title");
92 
93  auto h1Nbins0 = new G4UIparameter("nbins0", 'i', true);
94  h1Nbins0->SetGuidance("Number of bins (default = 100)");
95  h1Nbins0->SetGuidance("Can be reset with /analysis/h1/set command");
96  h1Nbins0->SetDefaultValue(100);
97 
98  auto h1ValMin0 = new G4UIparameter("valMin0", 'd', true);
99  h1ValMin0->SetGuidance("Minimum value, expressed in unit (default = 0.)");
100  h1ValMin0->SetGuidance("Can be reset with /analysis/h1/set command");
101  h1ValMin0->SetDefaultValue(0.);
102 
103  auto h1ValMax0 = new G4UIparameter("valMax0", 'd', true);
104  h1ValMax0->SetGuidance("Maximum value, expressed in unit (default = 1.)");
105  h1ValMax0->SetGuidance("Can be reset with /analysis/h1/set command");
106  h1ValMax0->SetDefaultValue(1.);
107 
108  auto h1ValUnit0 = new G4UIparameter("valUnit0", 's', true);
109  h1ValUnit0->SetGuidance("The unit applied to filled values and valMin0, valMax0");
110  h1ValUnit0->SetDefaultValue("none");
111 
112  auto h1ValFcn0 = new G4UIparameter("valFcn0", 's', true);
113  G4String fcnGuidance = "The function applied to filled values (log, log10, exp).\n";
114  fcnGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
115  fcnGuidance += "but none value should be used instead.";
116  h1ValFcn0->SetGuidance(fcnGuidance);
117  h1ValFcn0->SetParameterCandidates("log log10 exp none");
118  h1ValFcn0->SetDefaultValue("none");
119 
120  auto h1ValBinScheme0 = new G4UIparameter("valBinScheme0", 's', true);
121  G4String binSchemeGuidance = "The binning scheme (linear, log).\n";
122  h1ValBinScheme0->SetParameterCandidates("linear log");
123  binSchemeGuidance
124  += "Note that the unit and fcn parameters cannot be omitted in this case,\n";
125  binSchemeGuidance += "but none value should be used instead.";
126  h1ValBinScheme0->SetGuidance(binSchemeGuidance);
127  h1ValBinScheme0->SetDefaultValue("linear");
128 
129  fCreateH1Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/h1/create", this);
130  fCreateH1Cmd->SetGuidance("Create 1D histogram");
131  fCreateH1Cmd->SetParameter(h1Name);
132  fCreateH1Cmd->SetParameter(h1Title);
133  fCreateH1Cmd->SetParameter(h1Nbins0);
134  fCreateH1Cmd->SetParameter(h1ValMin0);
135  fCreateH1Cmd->SetParameter(h1ValMax0);
136  fCreateH1Cmd->SetParameter(h1ValUnit0);
137  fCreateH1Cmd->SetParameter(h1ValFcn0);
138  fCreateH1Cmd->SetParameter(h1ValBinScheme0);
139  fCreateH1Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
140 }
std::unique_ptr< G4UIcommand > fCreateH1Cmd
Here is the caller graph for this function:

◆ SetH1Cmd()

void G4H1Messenger::SetH1Cmd ( )
private

Definition at line 144 of file G4H1Messenger.cc.

145 {
146  auto h1Id = new G4UIparameter("id", 'i', false);
147  h1Id->SetGuidance("Histogram id");
148  h1Id->SetParameterRange("id>=0");
149 
150  auto h1Nbins = new G4UIparameter("nbins", 'i', false);
151  h1Nbins->SetGuidance("Number of bins");
152 
153  auto h1ValMin = new G4UIparameter("valMin", 'd', false);
154  h1ValMin->SetGuidance("Minimum value, expressed in unit");
155 
156  auto h1ValMax = new G4UIparameter("valMax", 'd', false);
157  h1ValMax->SetGuidance("Maximum value, expressed in unit");
158 
159  auto h1ValUnit = new G4UIparameter("valUnit", 's', true);
160  h1ValUnit->SetGuidance("The unit applied to filled values and valMin, valMax");
161  h1ValUnit->SetDefaultValue("none");
162 
163  auto h1ValFcn = new G4UIparameter("valFcn", 's', true);
164  h1ValFcn->SetParameterCandidates("log log10 exp none");
165  G4String fcnGuidance = "The function applied to filled values (log, log10, exp, none).\n";
166  fcnGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
167  fcnGuidance += "but none value should be used instead.";
168  h1ValFcn->SetGuidance(fcnGuidance);
169  h1ValFcn->SetDefaultValue("none");
170 
171  auto h1ValBinScheme = new G4UIparameter("valBinScheme", 's', true);
172  h1ValBinScheme->SetParameterCandidates("linear log");
173  G4String binSchemeGuidance = "The binning scheme (linear, log).\n";
174  binSchemeGuidance
175  += "Note that the unit and fcn parameters cannot be omitted in this case,\n";
176  binSchemeGuidance += "but none value should be used instead.";
177  h1ValBinScheme->SetGuidance(binSchemeGuidance);
178  h1ValBinScheme->SetDefaultValue("linear");
179 
180  fSetH1Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/h1/set", this);
181  fSetH1Cmd->SetGuidance("Set parameters for the 1D histogram of given id:");
182  fSetH1Cmd->SetGuidance(" nbins; valMin; valMax; unit; function; binScheme");
183  fSetH1Cmd->SetParameter(h1Id);
184  fSetH1Cmd->SetParameter(h1Nbins);
185  fSetH1Cmd->SetParameter(h1ValMin);
186  fSetH1Cmd->SetParameter(h1ValMax);
187  fSetH1Cmd->SetParameter(h1ValUnit);
188  fSetH1Cmd->SetParameter(h1ValFcn);
189  fSetH1Cmd->SetParameter(h1ValBinScheme);
190  fSetH1Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
191 }
std::unique_ptr< G4UIcommand > fSetH1Cmd
Here is the caller graph for this function:

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 198 of file G4H1Messenger.cc.

199 {
200  // tokenize parameters in a vector
201  std::vector<G4String> parameters;
202  G4Analysis::Tokenize(newValues, parameters);
203  // check consistency
204  if ( G4int(parameters.size()) != command->GetParameterEntries() ) {
205  // Should never happen but let's check anyway for consistency
206  fHelper->WarnAboutParameters(command, parameters.size());
207  return;
208  }
209 
210  if ( command == fCreateH1Cmd.get() ) {
211  auto counter = 0;
212  auto name = parameters[counter++];
213  auto title = parameters[counter++];
215  fHelper->GetBinData(xdata, parameters, counter);
216  auto unit = GetUnitValue(xdata.fSunit);
218  xdata.fNbins, xdata.fVmin*unit, xdata.fVmax*unit,
219  xdata.fSunit, xdata.fSfcn, xdata.fSbinScheme);
220  }
221  else if ( command == fSetH1Cmd.get() ) {
222  auto counter = 0;
223  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
225  fHelper->GetBinData(xdata, parameters, counter);
226  auto unit = GetUnitValue(xdata.fSunit);
227  fManager->SetH1(id,
228  xdata.fNbins, xdata.fVmin*unit, xdata.fVmax*unit,
229  xdata.fSunit, xdata.fSfcn, xdata.fSbinScheme);
230  }
231  else if ( command == fSetH1XCmd.get() ) {
232  auto counter = 0;
233  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
235  fHelper->GetBinData(xdata, parameters, counter);
236  auto unit = GetUnitValue(xdata.fSunit);
237  fManager->SetH1(id,
238  xdata.fNbins, xdata.fVmin*unit, xdata.fVmax*unit,
239  xdata.fSunit, xdata.fSfcn, xdata.fSbinScheme);
240  }
241  else if ( command == fSetH1TitleCmd.get() ) {
242  auto counter = 0;
243  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
244  auto title = parameters[counter++];
245  fManager->SetH1Title(id, title);
246  }
247  else if ( command == fSetH1XAxisCmd.get() ) {
248  auto counter = 0;
249  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
250  auto xaxis = parameters[counter++];
252  }
253  else if ( command == fSetH1YAxisCmd.get() ) {
254  auto counter = 0;
255  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
256  auto yaxis = parameters[counter++];
257  fManager->SetH1YAxisTitle(id, yaxis);
258  }
259 }
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")
std::unique_ptr< G4UIcommand > fSetH1XCmd
G4String name
Definition: TRTMaterials.hh:40
std::unique_ptr< G4UIcommand > fSetH1TitleCmd
std::unique_ptr< G4UIcommand > fSetH1XAxisCmd
int G4int
Definition: G4Types.hh:78
std::unique_ptr< G4UIcommand > fSetH1Cmd
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)
G4double GetUnitValue(const G4String &unit)
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:435
TGaxis * xaxis
Definition: plot_hist.C:61
std::unique_ptr< G4UIcommand > fSetH1YAxisCmd
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143
std::unique_ptr< G4UIcommand > fCreateH1Cmd
G4bool SetH1Title(G4int id, const G4String &title)
subroutine title
Definition: hijing1.383.f:5981
std::unique_ptr< G4AnalysisMessengerHelper > fHelper
G4bool SetH1XAxisTitle(G4int id, const G4String &title)
G4VAnalysisManager * fManager
Associated class.
Here is the call graph for this function:

Member Data Documentation

◆ fCreateH1Cmd

std::unique_ptr<G4UIcommand> G4H1Messenger::fCreateH1Cmd
private

Definition at line 67 of file G4H1Messenger.hh.

◆ fDirectory

std::unique_ptr<G4UIdirectory> G4H1Messenger::fDirectory
private

Definition at line 65 of file G4H1Messenger.hh.

◆ fHelper

std::unique_ptr<G4AnalysisMessengerHelper> G4H1Messenger::fHelper
private

Definition at line 64 of file G4H1Messenger.hh.

◆ fManager

G4VAnalysisManager* G4H1Messenger::fManager
private

Associated class.

Definition at line 63 of file G4H1Messenger.hh.

◆ fSetH1Cmd

std::unique_ptr<G4UIcommand> G4H1Messenger::fSetH1Cmd
private

Definition at line 68 of file G4H1Messenger.hh.

◆ fSetH1TitleCmd

std::unique_ptr<G4UIcommand> G4H1Messenger::fSetH1TitleCmd
private

Definition at line 70 of file G4H1Messenger.hh.

◆ fSetH1XAxisCmd

std::unique_ptr<G4UIcommand> G4H1Messenger::fSetH1XAxisCmd
private

Definition at line 71 of file G4H1Messenger.hh.

◆ fSetH1XCmd

std::unique_ptr<G4UIcommand> G4H1Messenger::fSetH1XCmd
private

Definition at line 69 of file G4H1Messenger.hh.

◆ fSetH1YAxisCmd

std::unique_ptr<G4UIcommand> G4H1Messenger::fSetH1YAxisCmd
private

Definition at line 72 of file G4H1Messenger.hh.


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