Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
G4NtupleMessenger Class Reference

#include <G4NtupleMessenger.hh>

Inheritance diagram for G4NtupleMessenger:
G4UImessenger

Public Member Functions

G4bool CommandsShouldBeInMaster () const
 
 G4NtupleMessenger ()=delete
 
 G4NtupleMessenger (G4VAnalysisManager *manager)
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool operator== (const G4UImessenger &messenger) const
 
virtual void SetNewValue (G4UIcommand *command, G4String value) final
 
virtual ~G4NtupleMessenger ()
 

Protected Member Functions

void AddUIcommand (G4UIcommand *newCommand)
 
G4String BtoS (G4bool b)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
G4String DtoS (G4double a)
 
G4String ItoS (G4int i)
 
G4bool StoB (G4String s)
 
G4double StoD (G4String s)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 

Protected Attributes

G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Private Member Functions

void SetActivationCmd ()
 
void SetActivationToAllCmd ()
 
void SetFileNameCmd ()
 
void SetFileNameToAllCmd ()
 

Private Attributes

G4VAnalysisManagerfManager { nullptr }
 Associated class. More...
 
std::unique_ptr< G4UIdirectoryfNtupleDir
 
std::unique_ptr< G4UIcmdWithABoolfSetActivationAllCmd
 
std::unique_ptr< G4UIcommandfSetActivationCmd
 
std::unique_ptr< G4UIcmdWithAStringfSetFileNameAllCmd
 
std::unique_ptr< G4UIcommandfSetFileNameCmd
 

Static Private Attributes

static constexpr std::string_view fkClass { "G4NtupleMessenger" }
 

Detailed Description

Definition at line 46 of file G4NtupleMessenger.hh.

Constructor & Destructor Documentation

◆ G4NtupleMessenger() [1/2]

G4NtupleMessenger::G4NtupleMessenger ( G4VAnalysisManager manager)
explicit

Definition at line 57 of file G4NtupleMessenger.cc.

58 : G4UImessenger(),
59 fManager(manager)
60{
61 fNtupleDir = std::make_unique<G4UIdirectory>("/analysis/ntuple/");
62 fNtupleDir->SetGuidance("ntuple control");
63
68}
G4VAnalysisManager * fManager
Associated class.
std::unique_ptr< G4UIdirectory > fNtupleDir

References fNtupleDir, SetActivationCmd(), SetActivationToAllCmd(), SetFileNameCmd(), and SetFileNameToAllCmd().

◆ G4NtupleMessenger() [2/2]

G4NtupleMessenger::G4NtupleMessenger ( )
delete

◆ ~G4NtupleMessenger()

G4NtupleMessenger::~G4NtupleMessenger ( )
virtualdefault

Member Function Documentation

◆ AddUIcommand()

void G4UImessenger::AddUIcommand ( G4UIcommand newCommand)
protectedinherited

Definition at line 149 of file G4UImessenger.cc.

150{
151 G4cerr << "Warning : Old style definition of G4UIcommand <"
152 << newCommand->GetCommandPath() << ">." << G4endl;
153}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:136

References G4cerr, G4endl, and G4UIcommand::GetCommandPath().

◆ BtoS()

G4String G4UImessenger::BtoS ( G4bool  b)
protectedinherited

Definition at line 98 of file G4UImessenger.cc.

99{
100 G4String vl = "0";
101 if(b)
102 vl = "true";
103 return vl;
104}

◆ CommandsShouldBeInMaster()

G4bool G4UImessenger::CommandsShouldBeInMaster ( ) const
inlineinherited

Definition at line 77 of file G4UImessenger.hh.

78 {
80 }
G4bool commandsShouldBeInMaster

References G4UImessenger::commandsShouldBeInMaster.

Referenced by G4UIcommand::G4UIcommandCommonConstructorCode().

◆ CreateCommand()

template<typename T >
T * G4UImessenger::CreateCommand ( const G4String cname,
const G4String dsc 
)
protectedinherited

Definition at line 110 of file G4UImessenger.hh.

111{
112 G4String path;
113 if(cname[0] != '/')
114 {
115 path = baseDirName + cname;
116 if(path[0] != '/')
117 path = "/" + path;
118 }
119
120 T* command = new T(path.c_str(), this);
121 command->SetGuidance(dsc.c_str());
122
123 return command;
124}
G4String baseDirName

References G4UImessenger::baseDirName.

◆ CreateDirectory()

void G4UImessenger::CreateDirectory ( const G4String path,
const G4String dsc,
G4bool  commandsToBeBroadcasted = true 
)
protectedinherited

Definition at line 156 of file G4UImessenger.cc.

158{
160
161 G4String fullpath = path;
162 if(fullpath.back() != '/')
163 fullpath.append("/");
164
165 G4UIcommandTree* tree = ui->GetTree()->FindCommandTree(fullpath.c_str());
166 if(tree != nullptr)
167 {
168 baseDirName = tree->GetPathName();
169 }
170 else
171 {
172 baseDir = new G4UIdirectory(fullpath.c_str(), commandsToBeBroadcasted);
173 baseDirName = fullpath;
174 baseDir->SetGuidance(dsc.c_str());
175 }
176}
const G4String & GetPathName() const
G4UIcommandTree * FindCommandTree(const char *commandPath)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4UIdirectory * baseDir

References G4UImessenger::baseDir, G4UImessenger::baseDirName, G4UIcommandTree::FindCommandTree(), G4UIcommandTree::GetPathName(), G4UImanager::GetTree(), G4UImanager::GetUIpointer(), and G4UIcommand::SetGuidance().

Referenced by G4MoleculeShootMessenger::G4MoleculeShootMessenger(), and G4UImessenger::G4UImessenger().

◆ DtoS()

G4String G4UImessenger::DtoS ( G4double  a)
protectedinherited

Definition at line 90 of file G4UImessenger.cc.

91{
92 std::ostringstream os;
93 os << a;
94 return G4String(os.str());
95}

Referenced by G4ScoreQuantityMessenger::FilterCommands(), and G4UIcontrolMessenger::SetNewValue().

◆ GetCurrentValue()

G4String G4UImessenger::GetCurrentValue ( G4UIcommand command)
virtualinherited

Reimplemented in G4ScoreQuantityMessenger, G4VisCommandModelCreate< Factory >, G4VisCommandListManagerList< Manager >, G4VisCommandListManagerSelect< Manager >, G4VisCommandManagerMode< Manager >, G4ToolsAnalysisMessenger, G4ScoringMessenger, G4EvManMessenger, G4GeneralParticleSourceMessenger, G4ParticleGunMessenger, G4GeometryMessenger, G4GenericMessenger, G4UIcontrolMessenger, GFlashShowerModelMessenger, G4DecayTableMessenger, G4ParticleMessenger, G4ParticlePropertyMessenger, G4tgrMessenger, G4PersistencyCenterMessenger, G4ProductionCutsTableMessenger, G4SchedulerMessenger, G4VITSteppingVerbose, G4MoleculeShootMessenger, G4MoleculeGunMessenger, G4ProcessManagerMessenger, G4ProcessTableMessenger, G4MatScanMessenger, G4RunMessenger, G4UserPhysicsListMessenger, G4TrackingMessenger, G4GMocrenMessenger, G4HepRepMessenger, G4VisCommandAbortReviewKeptEvents, G4VisCommandDrawOnlyToBeKeptEvents, G4VisCommandEnable, G4VisCommandList, G4VisCommandReviewKeptEvents, G4VisCommandVerbose, G4VisCommandGeometryList, G4VisCommandGeometryRestore, G4VisCommandGeometrySetColour, G4VisCommandGeometrySetDaughtersInvisible, G4VisCommandGeometrySetForceAuxEdgeVisible, G4VisCommandGeometrySetForceCloud, G4VisCommandGeometrySetForceSolid, G4VisCommandGeometrySetForceLineSegmentsPerCircle, G4VisCommandGeometrySetForceWireframe, G4VisCommandGeometrySetLineStyle, G4VisCommandGeometrySetLineWidth, G4VisCommandGeometrySetVisibility, G4VisCommandSceneActivateModel, G4VisCommandSceneCreate, G4VisCommandSceneEndOfEventAction, G4VisCommandSceneEndOfRunAction, G4VisCommandSceneList, G4VisCommandSceneNotifyHandlers, G4VisCommandSceneRemoveModel, G4VisCommandSceneSelect, G4VisCommandSceneShowExtents, G4VisCommandSceneAddArrow, G4VisCommandSceneAddArrow2D, G4VisCommandSceneAddAxes, G4VisCommandSceneAddDate, G4VisCommandSceneAddDigis, G4VisCommandSceneAddEventID, G4VisCommandSceneAddExtent, G4VisCommandSceneAddElectricField, G4VisCommandSceneAddFrame, G4VisCommandSceneAddGPS, G4VisCommandSceneAddGhosts, G4VisCommandSceneAddHits, G4VisCommandSceneAddLine, G4VisCommandSceneAddLine2D, G4VisCommandSceneAddLocalAxes, G4VisCommandSceneAddLogicalVolume, G4VisCommandSceneAddLogo, G4VisCommandSceneAddLogo2D, G4VisCommandSceneAddMagneticField, G4VisCommandSceneAddPSHits, G4VisCommandSceneAddScale, G4VisCommandSceneAddText, G4VisCommandSceneAddText2D, G4VisCommandSceneAddTrajectories, G4VisCommandSceneAddUserAction, G4VisCommandSceneAddVolume, G4VisCommandSceneAddPlotter, G4VisCommandSceneHandlerAttach, G4VisCommandSceneHandlerCreate, G4VisCommandSceneHandlerList, G4VisCommandSceneHandlerSelect, G4VisCommandSetArrow3DLineSegmentsPerCircle, G4VisCommandSetColour, G4VisCommandSetExtentForField, G4VisCommandSetLineWidth, G4VisCommandSetTextColour, G4VisCommandSetTextLayout, G4VisCommandSetTextSize, G4VisCommandSetTouchable, G4VisCommandSetVolumeForField, G4VisCommandsTouchable, G4VisCommandsTouchableSet, G4VisCommandViewerAddCutawayPlane, G4VisCommandViewerCentreOn, G4VisCommandViewerChangeCutawayPlane, G4VisCommandViewerClear, G4VisCommandViewerClearCutawayPlanes, G4VisCommandViewerClearTransients, G4VisCommandViewerClearVisAttributesModifiers, G4VisCommandViewerClone, G4VisCommandViewerColourByDensity, G4VisCommandViewerCopyViewFrom, G4VisCommandViewerCreate, G4VisCommandViewerDolly, G4VisCommandViewerFlush, G4VisCommandViewerInterpolate, G4VisCommandViewerList, G4VisCommandViewerPan, G4VisCommandViewerReset, G4VisCommandViewerRefresh, G4VisCommandViewerRebuild, G4VisCommandViewerSave, G4VisCommandViewerScale, G4VisCommandViewerSelect, G4VisCommandViewerUpdate, G4VisCommandViewerZoom, G4VisCommandViewerDefaultHiddenEdge, G4VisCommandViewerDefaultStyle, G4VisCommandsViewerSet, G4VModelCommand< T >, G4VModelCommand< M >, G4RTMessenger, G4ASCIITreeMessenger, G4VtkMessenger, G4PolarizationMessenger, and G4DNAChemistryManager.

Definition at line 58 of file G4UImessenger.cc.

59{
60 G4String nullString;
61 return nullString;
62}

Referenced by G4UIcommand::DoIt(), and G4UIcommand::GetCurrentValue().

◆ ItoS()

G4String G4UImessenger::ItoS ( G4int  i)
protectedinherited

Definition at line 82 of file G4UImessenger.cc.

83{
84 std::ostringstream os;
85 os << i;
86 return G4String(os.str());
87}

Referenced by G4GenericMessenger::DeclareMethod(), and G4ParticleGunMessenger::GetCurrentValue().

◆ operator!=()

G4bool G4UImessenger::operator!= ( const G4UImessenger messenger) const
inherited

Definition at line 76 of file G4UImessenger.cc.

77{
78 return this != &messenger;
79}

◆ operator==()

G4bool G4UImessenger::operator== ( const G4UImessenger messenger) const
inherited

Definition at line 70 of file G4UImessenger.cc.

71{
72 return this == &messenger;
73}

◆ SetActivationCmd()

void G4NtupleMessenger::SetActivationCmd ( )
private

Definition at line 78 of file G4NtupleMessenger.cc.

79{
80 auto ntupleId = new G4UIparameter("NtupleId", 'i', false);
81 ntupleId->SetGuidance("Ntuple id");
82 ntupleId->SetParameterRange("NtupleId>=0");
83
84 auto ntupleActivation = new G4UIparameter("NtupleActivation", 's', true);
85 ntupleActivation->SetGuidance("Ntuple activation");
86 ntupleActivation->SetDefaultValue("none");
87
88 fSetActivationCmd = std::make_unique<G4UIcommand>("/analysis/ntuple/setActivation", this);
89 G4String guidance("Set activation for the ntuple of given id");
90
91 fSetActivationCmd->SetGuidance(guidance);
92 fSetActivationCmd->SetParameter(ntupleId);
93 fSetActivationCmd->SetParameter(ntupleActivation);
95}
@ G4State_Idle
@ G4State_PreInit
std::unique_ptr< G4UIcommand > fSetActivationCmd

References fSetActivationCmd, G4State_Idle, and G4State_PreInit.

Referenced by G4NtupleMessenger().

◆ SetActivationToAllCmd()

void G4NtupleMessenger::SetActivationToAllCmd ( )
private

Definition at line 98 of file G4NtupleMessenger.cc.

99{
101 = std::make_unique<G4UIcmdWithABool>("/analysis/ntuple/setActivationToAll", this);
102 G4String guidance("Set activation to all ntuples");
103 fSetActivationAllCmd->SetGuidance(guidance);
104 fSetActivationAllCmd->SetParameterName("AllNtupleActivation",false);
105}
std::unique_ptr< G4UIcmdWithABool > fSetActivationAllCmd

References fSetActivationAllCmd.

Referenced by G4NtupleMessenger().

◆ SetFileNameCmd()

void G4NtupleMessenger::SetFileNameCmd ( )
private

Definition at line 108 of file G4NtupleMessenger.cc.

109{
110 auto ntupleId = new G4UIparameter("NtupleId", 'i', false);
111 ntupleId->SetGuidance("Ntuple id");
112 ntupleId->SetParameterRange("NtupleId>=0");
113
114 auto ntupleFileName = new G4UIparameter("NtupleFileName", 's', true);
115 ntupleFileName->SetGuidance("Ntuple file name");
116 ntupleFileName->SetDefaultValue("none");
117
118 fSetFileNameCmd = std::make_unique<G4UIcommand>("/analysis/ntuple/setFileName", this);
119 G4String guidance("Set file name for the ntuple of given id");
120
121 fSetFileNameCmd->SetGuidance(guidance);
122 fSetFileNameCmd->SetParameter(ntupleId);
123 fSetFileNameCmd->SetParameter(ntupleFileName);
124 fSetFileNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
125}
std::unique_ptr< G4UIcommand > fSetFileNameCmd

References fSetFileNameCmd, G4State_Idle, and G4State_PreInit.

Referenced by G4NtupleMessenger().

◆ SetFileNameToAllCmd()

void G4NtupleMessenger::SetFileNameToAllCmd ( )
private

Definition at line 128 of file G4NtupleMessenger.cc.

129{
131 = std::make_unique<G4UIcmdWithAString>("/analysis/ntuple/setFileNameToAll", this);
132 G4String guidance("Set file name to all ntuples");
133 fSetFileNameAllCmd->SetGuidance(guidance);
134 fSetFileNameAllCmd->SetParameterName("AllNtupleFileName",false);
135}
std::unique_ptr< G4UIcmdWithAString > fSetFileNameAllCmd

References fSetFileNameAllCmd.

Referenced by G4NtupleMessenger().

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 142 of file G4NtupleMessenger.cc.

143{
144 if ( command == fSetActivationCmd.get() ) {
145 // tokenize parameters in a vector
146 std::vector<G4String> parameters;
147 G4Analysis::Tokenize(newValues, parameters);
148 // check consistency
149 if ( parameters.size() == command->GetParameterEntries() ) {
150 auto counter = 0;
151 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
152 auto activation = G4UIcommand::ConvertToBool(parameters[counter++]);
153 fManager->SetNtupleActivation(id, activation);
154 }
155 else {
156 // Should never happen but let's check anyway for consistency
158 parameters.size(),command->GetParameterEntries(), fkClass);
159 }
160 }
161 else if ( command == fSetActivationAllCmd.get() ) {
162 auto activation = fSetActivationAllCmd->GetNewBoolValue(newValues);
163 fManager->SetNtupleActivation(activation);
164 }
165 else if ( command == fSetFileNameCmd.get() ) {
166 // tokenize parameters in a vector
167 std::vector<G4String> parameters;
168 G4Analysis::Tokenize(newValues, parameters);
169 // check consistency
170 if ( parameters.size() == command->GetParameterEntries() ) {
171 auto counter = 0;
172 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
173 auto fileName = parameters[counter++];
174 fManager->SetNtupleFileName(id, fileName);
175 }
176 else {
177 // Should never happen but let's check anyway for consistency
179 parameters.size(),command->GetParameterEntries(), fkClass);
180 }
181 }
182 else if ( command == fSetFileNameAllCmd.get() ) {
183 auto fileName = newValues;
184 fManager->SetNtupleFileName(fileName);
185 }
186}
static constexpr std::string_view fkClass
std::size_t GetParameterEntries() const
Definition: G4UIcommand.hh:138
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:557
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:545
const G4String & GetCommandName() const
Definition: G4UIcommand.hh:137
void SetNtupleFileName(const G4String &fileName)
void SetNtupleActivation(G4bool activation)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
void WrongParametersWarning(const G4String &commandName, std::size_t got, std::size_t expected, std::string_view className)

References G4UIcommand::ConvertToBool(), G4UIcommand::ConvertToInt(), fkClass, fManager, fSetActivationAllCmd, fSetActivationCmd, fSetFileNameAllCmd, fSetFileNameCmd, G4UIcommand::GetCommandName(), G4UIcommand::GetParameterEntries(), G4VAnalysisManager::SetNtupleActivation(), G4VAnalysisManager::SetNtupleFileName(), G4Analysis::Tokenize(), and anonymous_namespace{G4NtupleMessenger.cc}::WrongParametersWarning().

◆ StoB()

G4bool G4UImessenger::StoB ( G4String  s)
protectedinherited

Definition at line 137 of file G4UImessenger.cc.

138{
140 G4bool vl = false;
141 if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
142 {
143 vl = true;
144 }
145 return vl;
146}
bool G4bool
Definition: G4Types.hh:86
G4String to_upper_copy(G4String str)
Return uppercase copy of string.

References G4StrUtil::to_upper_copy().

Referenced by G4LocalThreadCoutMessenger::SetNewValue(), G4CascadeParamMessenger::SetNewValue(), G4ScoreQuantityMessenger::SetNewValue(), and G4ScoringMessenger::SetNewValue().

◆ StoD()

G4double G4UImessenger::StoD ( G4String  s)
protectedinherited

◆ StoI()

G4int G4UImessenger::StoI ( G4String  s)
protectedinherited

◆ StoL()

G4long G4UImessenger::StoL ( G4String  s)
protectedinherited

Definition at line 117 of file G4UImessenger.cc.

118{
119 G4long vl;
120 const char* t = str;
121 std::istringstream is(t);
122 is >> vl;
123 return vl;
124}
long G4long
Definition: G4Types.hh:87

Referenced by G4RunMessenger::SetNewValue().

Field Documentation

◆ baseDir

G4UIdirectory* G4UImessenger::baseDir = nullptr
protectedinherited

◆ baseDirName

G4String G4UImessenger::baseDirName = ""
protectedinherited

◆ commandsShouldBeInMaster

G4bool G4UImessenger::commandsShouldBeInMaster = false
protectedinherited

◆ fkClass

constexpr std::string_view G4NtupleMessenger::fkClass { "G4NtupleMessenger" }
staticconstexprprivate

Definition at line 64 of file G4NtupleMessenger.hh.

Referenced by SetNewValue().

◆ fManager

G4VAnalysisManager* G4NtupleMessenger::fManager { nullptr }
private

Associated class.

Definition at line 67 of file G4NtupleMessenger.hh.

Referenced by SetNewValue().

◆ fNtupleDir

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

Definition at line 69 of file G4NtupleMessenger.hh.

Referenced by G4NtupleMessenger().

◆ fSetActivationAllCmd

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

Definition at line 71 of file G4NtupleMessenger.hh.

Referenced by SetActivationToAllCmd(), and SetNewValue().

◆ fSetActivationCmd

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

Definition at line 70 of file G4NtupleMessenger.hh.

Referenced by SetActivationCmd(), and SetNewValue().

◆ fSetFileNameAllCmd

std::unique_ptr<G4UIcmdWithAString> G4NtupleMessenger::fSetFileNameAllCmd
private

Definition at line 73 of file G4NtupleMessenger.hh.

Referenced by SetFileNameToAllCmd(), and SetNewValue().

◆ fSetFileNameCmd

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

Definition at line 72 of file G4NtupleMessenger.hh.

Referenced by SetFileNameCmd(), and SetNewValue().


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