Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4THnMessenger.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26
27// Common implementation for histograms messengers.
28// It implements commands in /analysis/hn|pn directories
29//
30// Author: Ivana Hrivnacova, 26/08/2022 ([email protected])
31
32#ifndef G4THnMessenger_h
33#define G4THnMessenger_h 1
34
35#include "G4UImessenger.hh"
36#include "globals.hh"
37
38#include <memory>
39#include <array>
40#include <vector>
41#include <string_view>
42
44class G4UIdirectory;
45class G4UIcommand;
46struct G4HnDimension;
48
49template <unsigned int DIM, typename HT>
51
52template <unsigned int DIM, typename HT>
54{
55 public:
57 G4THnMessenger() = delete;
58 ~G4THnMessenger() override = default;
59
60 // Methods
62 void SetNewValue(G4UIcommand* command, G4String value) final;
63
64 private:
65 // Helper functions
66 G4String GetObjectType() const;
67 G4bool IsProfileLastDimension(unsigned int idim) const;
68 std::unique_ptr<G4UIcommand> CreateCommand(G4String name, G4String guideline);
69 void CreateDimensionParameters(unsigned int idim,
70 std::vector<G4UIparameter*>& parameters) const;
71 void AddIdParameter(G4UIcommand& command);
72 G4String GetTAddress(G4int id) const;
73 G4String GetTVectorAddress() const;
74
75 // Functions to create commands
76 void CreateDirectory() const;
77 void CreateCmd();
78 void SetCmd();
79 void DeleteCmd();
80 std::unique_ptr<G4UIcommand> CreateSetBinsCommand(unsigned int ibin);
81 void CreateSetTitleCommand();
82 std::unique_ptr<G4UIcommand> CreateSetAxisCommand(unsigned int ibin);
83 void CreateListCommand();
84 void CreateGetCommand();
85 void CreateGetVectorCommand();
86
87 // Functions to retrieve data
88 void GetBinData(unsigned int idim, G4int& counter,
89 const std::vector<G4String>& parameters, G4HnDimension& bins) const;
90 void GetBinInfoData(unsigned int idim, G4int& counter,
91 const std::vector<G4String>& parameters, G4HnDimension& bins,
92 G4HnDimensionInformation& info) const;
93 void GetData(G4int& counter, const std::vector<G4String>& parameters,
94 std::array<G4HnDimension, DIM>& bins,
95 std::array<G4HnDimensionInformation, DIM>& info) const;
96
97 // constants
98 static constexpr std::string_view fkClass { "G4THnMessenger" };
99
100 // Data members
101 G4THnToolsManager<DIM,HT>* fManager { nullptr }; ///< Associated class
102
103 std::unique_ptr<G4UIcommand> fCreateCmd;
104 std::unique_ptr<G4UIcommand> fSetCmd;
105 std::unique_ptr<G4UIcommand> fDeleteCmd;
106 std::array<std::unique_ptr<G4UIcommand>, DIM> fSetDimensionCmd;
107 std::unique_ptr<G4UIcommand> fSetTitleCmd;
108 std::array<std::unique_ptr<G4UIcommand>, DIM+1> fSetAxisCmd;
109 std::unique_ptr<G4UIcommand> fListCmd;
110 std::unique_ptr<G4UIcommand> fGetTCmd;
111 std::unique_ptr<G4UIcommand> fGetTVectorCmd;
112
113 std::array<unsigned int, DIM> fTmpId;
114 std::array<G4HnDimension, DIM> fTmpBins;
115 std::array<G4HnDimensionInformation, DIM> fTmpInfo;
116
117 G4String fTValue;
118 G4String fTVectorValue;
119};
120
121// #include "G4THnMessenger.icc"
122 // to avoid include recursion the implementation is included in G4THnToolsManager.hh
123
124#endif
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
void SetNewValue(G4UIcommand *command, G4String value) final
~G4THnMessenger() override=default
G4THnMessenger(G4THnToolsManager< DIM, HT > *manager)
G4String GetCurrentValue(G4UIcommand *command) final
G4THnMessenger()=delete