Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4NtupleMessenger Class Reference

#include <G4NtupleMessenger.hh>

Inheritance diagram for G4NtupleMessenger:
Collaboration diagram for G4NtupleMessenger:

Public Member Functions

 G4NtupleMessenger (G4VAnalysisManager *manager)
 
virtual ~G4NtupleMessenger ()
 
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 45 of file G4NtupleMessenger.hh.

Constructor & Destructor Documentation

G4NtupleMessenger::G4NtupleMessenger ( G4VAnalysisManager manager)
explicit

Definition at line 43 of file G4NtupleMessenger.cc.

44  : G4UImessenger(),
45  fManager(manager),
46  fSetActivationCmd(nullptr),
47  fSetActivationAllCmd(nullptr)
48 {
49  fNtupleDir = G4Analysis::make_unique<G4UIdirectory>("/analysis/ntuple/");
50  fNtupleDir->SetGuidance("ntuple control");
51 
52  SetActivationCmd();
53  SetActivationToAllCmd();
54 }
G4NtupleMessenger::~G4NtupleMessenger ( )
virtual

Definition at line 57 of file G4NtupleMessenger.cc.

58 {
59 }

Member Function Documentation

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

Reimplemented from G4UImessenger.

Definition at line 100 of file G4NtupleMessenger.cc.

101 {
102  if ( command == fSetActivationCmd.get() ) {
103  // tokenize parameters in a vector
104  std::vector<G4String> parameters;
105  G4Analysis::Tokenize(newValues, parameters);
106  // check consistency
107  if ( G4int(parameters.size()) == command->GetParameterEntries() ) {
108  auto counter = 0;
109  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
110  auto activation = G4UIcommand::ConvertToBool(parameters[counter++]);
111  fManager->SetNtupleActivation(id, activation);
112  }
113  else {
114  // Should never happen but let's check anyway for consistency
115  G4ExceptionDescription description;
116  description
117  << "Got wrong number of \"" << command->GetCommandName()
118  << "\" parameters: " << parameters.size()
119  << " instead of " << command->GetParameterEntries()
120  << " expected" << G4endl;
121  G4Exception("G4NtupleMessenger::SetNewValue",
122  "Analysis_W013", JustWarning, description);
123  }
124  }
125  else if ( command == fSetActivationAllCmd.get() ) {
126  auto activation = fSetActivationAllCmd->GetNewBoolValue(newValues);
127  fManager->SetNtupleActivation(activation);
128  }
129 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
int G4int
Definition: G4Types.hh:78
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:437
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:447
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
const G4String & GetCommandName() const
Definition: G4UIcommand.hh:141
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
#define G4endl
Definition: G4ios.hh:61
void SetNtupleActivation(G4bool activation)
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143

Here is the call graph for this function:


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