File indexing completed on 2025-01-18 09:58:45
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef G4NtupleMessenger_h
0035 #define G4NtupleMessenger_h 1
0036
0037 #include "G4AnalysisUtilities.hh"
0038 #include "G4UImessenger.hh"
0039 #include "globals.hh"
0040
0041 #include <map>
0042 #include <memory>
0043 #include <string_view>
0044
0045 class G4VAnalysisManager;
0046 class G4UIcommand;
0047 class G4UIcmdWithABool;
0048 class G4UIcmdWithAString;
0049
0050 class G4NtupleMessenger : public G4UImessenger
0051 {
0052 public:
0053 explicit G4NtupleMessenger(G4VAnalysisManager* manager);
0054 G4NtupleMessenger() = delete;
0055 ~G4NtupleMessenger() override;
0056
0057
0058 void SetNewValue(G4UIcommand* command, G4String value) final;
0059
0060 private:
0061
0062 template <typename CMD>
0063 std::unique_ptr<CMD> CreateCommand(G4String name, G4String guidance);
0064 void AddIdParameter(G4UIcommand& command);
0065
0066 void CreateCmd();
0067 void CreateColumnCmds();
0068 void FinishCmd();
0069 void DeleteCmd();
0070 void SetActivationCmd();
0071 void SetActivationToAllCmd();
0072 void SetFileNameCmd();
0073 void SetFileNameToAllCmd();
0074 void ListCmd();
0075
0076
0077 static constexpr std::string_view fkClass { "G4NtupleMessenger" };
0078
0079
0080 G4VAnalysisManager* fManager { nullptr };
0081
0082 std::unique_ptr<G4UIdirectory> fNtupleDir;
0083 std::unique_ptr<G4UIcommand> fCreateCmd;
0084 std::map<char, std::unique_ptr<G4UIcommand>> fCreateColumnCmds;
0085 std::unique_ptr<G4UIcommand> fFinishCmd;
0086 std::unique_ptr<G4UIcommand> fDeleteCmd;
0087 std::unique_ptr<G4UIcommand> fSetActivationCmd;
0088 std::unique_ptr<G4UIcmdWithABool> fSetActivationAllCmd;
0089 std::unique_ptr<G4UIcommand> fSetFileNameCmd;
0090 std::unique_ptr<G4UIcmdWithAString> fSetFileNameAllCmd;
0091 std::unique_ptr<G4UIcommand> fListCmd;
0092 G4int fTmpNtupleId { G4Analysis::kInvalidId };
0093 };
0094
0095
0096 template <typename CMD>
0097 std::unique_ptr<CMD> G4NtupleMessenger::CreateCommand(
0098 G4String name, G4String guidance)
0099 {
0100 G4String fullName = "/analysis/ntuple/" + name;
0101
0102 auto command = std::make_unique<CMD>(fullName, this);
0103 command->SetGuidance(guidance.c_str());
0104 command->AvailableForStates(G4State_PreInit, G4State_Idle);
0105
0106 return command;
0107 }
0108
0109 #endif