Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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
 

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 ( 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 }
G4H1Messenger::~G4H1Messenger ( )
virtual

Definition at line 77 of file G4H1Messenger.cc.

78 {}

Member Function Documentation

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);
217  fManager->CreateH1(name, title,
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++];
251  fManager->SetH1XAxisTitle(id, xaxis);
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 }
const XML_Char * name
Definition: expat.h:151
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")
int G4int
Definition: G4Types.hh:78
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:447
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4bool SetH1Title(G4int id, const G4String &title)
subroutine title
Definition: hijing1.383.f:5980
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143
G4bool SetH1XAxisTitle(G4int id, const G4String &title)

Here is the call graph for this function:


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