Geant4  10.02.p03
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
 

Private Member Functions

void SetActivationCmd ()
 
void SetActivationToAllCmd ()
 

Private Attributes

G4VAnalysisManagerfManager
 Associated class. More...
 
std::unique_ptr< G4UIdirectoryfNtupleDir
 
std::unique_ptr< G4UIcommandfSetActivationCmd
 
std::unique_ptr< G4UIcmdWithABoolfSetActivationAllCmd
 

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::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 
54 }
std::unique_ptr< G4UIdirectory > fNtupleDir
std::unique_ptr< G4UIcmdWithABool > fSetActivationAllCmd
G4VAnalysisManager * fManager
Associated class.
std::unique_ptr< G4UIcommand > fSetActivationCmd
Here is the call graph for this function:

◆ ~G4NtupleMessenger()

G4NtupleMessenger::~G4NtupleMessenger ( )
virtual

Definition at line 57 of file G4NtupleMessenger.cc.

58 {
59 }

Member Function Documentation

◆ SetActivationCmd()

void G4NtupleMessenger::SetActivationCmd ( )
private

Definition at line 66 of file G4NtupleMessenger.cc.

67 {
68  auto ntupleId = new G4UIparameter("NtupleId", 'i', false);
69  ntupleId->SetGuidance("Ntuple id");
70  ntupleId->SetParameterRange("NtupleId>=0");
71 
72  auto ntupleActivation = new G4UIparameter("NtupleActivation", 's', true);
73  ntupleActivation->SetGuidance("Ntuple activation");
74  ntupleActivation->SetDefaultValue("none");
75 
76  fSetActivationCmd = G4Analysis::make_unique<G4UIcommand>("/analysis/ntuple/setActivation", this);
77  G4String guidance("Set activation for the ntuple of given id");
78 
79  fSetActivationCmd->SetGuidance(guidance);
80  fSetActivationCmd->SetParameter(ntupleId);
81  fSetActivationCmd->SetParameter(ntupleActivation);
82  fSetActivationCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
83 }
std::unique_ptr< G4UIcommand > fSetActivationCmd
Here is the caller graph for this function:

◆ SetActivationToAllCmd()

void G4NtupleMessenger::SetActivationToAllCmd ( )
private

Definition at line 86 of file G4NtupleMessenger.cc.

87 {
89  = G4Analysis::make_unique<G4UIcmdWithABool>("/analysis/ntuple/setActivationToAll", this);
90  G4String guidance("Set activation to all ntuples");
91  fSetActivationAllCmd->SetGuidance(guidance);
92  fSetActivationAllCmd->SetParameterName("AllNtupleActivation",false);
93 }
std::unique_ptr< G4UIcmdWithABool > fSetActivationAllCmd
Here is the caller graph for this function:

◆ SetNewValue()

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 }
const G4String & GetCommandName() const
Definition: G4UIcommand.hh:141
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
int G4int
Definition: G4Types.hh:78
std::unique_ptr< G4UIcmdWithABool > fSetActivationAllCmd
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:425
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:435
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4VAnalysisManager * fManager
Associated class.
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143
#define G4endl
Definition: G4ios.hh:61
void SetNtupleActivation(G4bool activation)
std::unique_ptr< G4UIcommand > fSetActivationCmd
Here is the call graph for this function:

Member Data Documentation

◆ fManager

G4VAnalysisManager* G4NtupleMessenger::fManager
private

Associated class.

Definition at line 58 of file G4NtupleMessenger.hh.

◆ fNtupleDir

std::unique_ptr<G4UIdirectory> G4NtupleMessenger::fNtupleDir
private

Definition at line 60 of file G4NtupleMessenger.hh.

◆ fSetActivationAllCmd

std::unique_ptr<G4UIcmdWithABool> G4NtupleMessenger::fSetActivationAllCmd
private

Definition at line 62 of file G4NtupleMessenger.hh.

◆ fSetActivationCmd

std::unique_ptr<G4UIcommand> G4NtupleMessenger::fSetActivationCmd
private

Definition at line 61 of file G4NtupleMessenger.hh.


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