45 fAnalysisDir = std::make_unique<G4UIdirectory>(
"/analysis/");
46 fAnalysisDir->SetGuidance(
"analysis control");
48 fOpenFileCmd = CreateCommand<G4UIcmdWithAString>(
49 "openFile",
"Open analysis file",
"FileName",
true);
50 fOpenFileCmd->SetDefaultValue(
"");
51 fOpenFileCmd->SetToBeBroadcasted(
true);
53 fWriteCmd = CreateCommandWithoutParameter(
54 "write",
"Write analysis data.");
55 fWriteCmd->SetToBeBroadcasted(
false);
57 fResetCmd = CreateCommandWithoutParameter(
58 "reset",
"Reset analysis data.");
59 fResetCmd->SetToBeBroadcasted(
false);
61 fCloseFileCmd = CreateCommand<G4UIcmdWithABool>(
62 "closeFile",
"Close analysis file and (optionally) reset data.",
"IsReset",
true);
63 fCloseFileCmd->SetDefaultValue(
true);
64 fCloseFileCmd->SetToBeBroadcasted(
false);
66 fListCmd = CreateCommand<G4UIcmdWithABool>(
67 "list",
"List all/activate analysis objects.",
"OnlyIfActive",
true);
68 fListCmd->SetDefaultValue(
true);
70 fSetActivationCmd = CreateCommand<G4UIcmdWithABool>(
73 "When this option is enabled, only the histograms marked as activated\n"
74 "are returned, filled or saved on file.\n"
75 "No warning is issued when Get or Fill is called on inactive histogram.",
78 fVerboseCmd = CreateCommand<G4UIcmdWithAnInteger>(
79 "verbose",
"Set verbose level",
"VerboseLevel");
80 fVerboseCmd->SetRange(
"VerboseLevel>=0 && VerboseLevel<=4");
82 fCompressionCmd = CreateCommand<G4UIcmdWithAnInteger>(
83 "compression",
"Set compression level",
"CompressionLevel");
84 fCompressionCmd->SetRange(
"CompressionLevel>=0 && CompressionLevel<=4");
86 fSetFileNameCmd = CreateCommand<G4UIcmdWithAString>(
87 "setFileName",
"Set name for the histograms & ntuple file",
"Filename");
89 fSetHistoDirNameCmd = CreateCommand<G4UIcmdWithAString>(
90 "setHistoDirName",
"Set name for the histograms directory",
"HistoDirName");
92 fSetNtupleDirNameCmd = CreateCommand<G4UIcmdWithAString>(
93 "setNtupleDirName",
"Set name for the ntuple directory",
"NtupleDirName");
95 fNtupleMessenger = std::make_unique<G4NtupleMessenger>(manager);
107std::unique_ptr<G4UIcmdWithoutParameter>
108G4AnalysisMessenger::CreateCommandWithoutParameter(
111 G4String fullName =
"/analysis/" + name;
113 auto command = std::make_unique<G4UIcmdWithoutParameter>(fullName,
this);
114 command->SetGuidance(guidance.c_str());
127 if ( command == fOpenFileCmd.get() ) {
133 if ( command == fWriteCmd.get() ) {
134 fManager->WriteFromUI();
138 if ( command == fResetCmd.get() ) {
139 fManager->ResetFromUI();
143 if ( command == fCloseFileCmd.get() ) {
144 fManager->CloseFileFromUI(fCloseFileCmd->GetNewBoolValue(newValues));
148 if ( command == fListCmd.get() ) {
149 fManager->
List(fListCmd->GetNewBoolValue(newValues));
153 if ( command == fSetActivationCmd.get() ) {
154 fManager->
SetActivation(fSetActivationCmd->GetNewBoolValue(newValues));
158 if ( command == fVerboseCmd.get() ) {
163 if ( command == fCompressionCmd.get() ) {
168 if ( command == fSetFileNameCmd.get() ) {
173 if ( command == fSetHistoDirNameCmd.get() ) {
178 if ( command == fSetNtupleDirNameCmd.get() ) {
G4AnalysisMessenger()=delete
~G4AnalysisMessenger() override
void SetNewValue(G4UIcommand *command, G4String value) final
void SetActivation(G4bool activation)
G4bool OpenFile(const G4String &fileName="")
G4bool SetHistoDirectoryName(const G4String &dirName)
void SetVerboseLevel(G4int verboseLevel)
G4bool List(G4bool onlyIfActive=true) const
G4bool SetFileName(const G4String &fileName)
void SetCompressionLevel(G4int level)
G4bool SetNtupleDirectoryName(const G4String &dirName)