Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4HnManager.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// Class for management of G4HnInformation.
28// It implements functions handling the added H1/H2 information
29// (not available in g4tools).
30//
31// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
32
33#ifndef G4HnManager_h
34#define G4HnManager_h 1
35
37#include "G4HnInformation.hh"
38#include "globals.hh"
39
40#include <string_view>
41#include <utility>
42#include <vector>
43
44class G4VFileManager;
45class G4HnMessenger;
46
48{
49 public:
50 G4HnManager(G4String hnType, const G4AnalysisManagerState& state);
51 G4HnManager() = delete;
52 ~G4HnManager() override;
53
54 // Methods to manipulate additional information
55
56 G4HnInformation* AddHnInformation(const G4String& name, G4int nofDimensions);
57
58 void ClearData();
59
60 // Access methofd
62 std::string_view functionName,
63 G4bool warn = true) const;
64
66 G4int dimension,
67 std::string_view functionName,
68 G4bool warn = true) const;
69
70 const std::vector<G4HnInformation*>& GetHnVector() const;
71 G4int GetNofHns() const;
72 G4int GetNofActiveHns() const;
73 G4String GetHnType() const;
74
75 // Activation option
76
77 // Return false if activation is enabled and there is no object activated,
78 // return true otherwise
79 G4bool IsActive() const;
80
81 // ASCII option
82
83 // Return false if there is no object selected for ASCII output,
84 // return true otherwise
85 G4bool IsAscii() const;
86
87 // Plotting option
88
89 // Return false if there is no object selected for plotting,
90 // return true otherwise
91 G4bool IsPlotting() const;
92
93 // Return false if there is no object with a specific file name
94 G4bool IsFileName() const;
95
96 // Function implementing public analysis manager interface
97 //
98 void SetActivation(G4bool activation);
99 void SetActivation(G4int id, G4bool activation);
100 void SetAscii(G4int id, G4bool ascii);
101 void SetPlotting(G4int id, G4bool plotting);
102 void SetPlotting(G4bool plotting);
103 void SetFileName(G4int id, const G4String& fileName);
104 void SetFileName(const G4String& fileName);
105 G4bool SetAxisIsLog(unsigned int idim, G4int id, G4bool isLogAxis);
106
107
108 // Access to Hn additional information
109 G4String GetName(G4int id) const;
110 G4double GetUnit(unsigned int idim, G4int id) const;
111 G4bool GetAxisIsLog(unsigned int idim, G4int id) const;
112 G4bool GetActivation(G4int id) const;
113 G4bool GetAscii(G4int id) const;
114 G4bool GetPlotting(G4int id) const;
115 G4String GetFileName(G4int id) const;
116
117 void SetFileManager(std::shared_ptr<G4VFileManager> fileManager);
118
119 private:
120 // Methods
121 void SetActivation(G4HnInformation* info, G4bool activation);
122 void SetPlotting(G4HnInformation* info, G4bool plotting);
123 void SetFileName(G4HnInformation* info, const G4String& fileName);
124
125 // Static data members
126 static constexpr std::string_view fkClass { "G4HnManager" };
127
128 // Data members
129 G4String fHnType;
130 G4int fNofActiveObjects { 0 };
131 G4int fNofAsciiObjects { 0 };
132 G4int fNofPlottingObjects { 0 };
133 G4int fNofFileNameObjects { 0 };
134
135 // Additional histograms/ntuple properties not included in tools
136 std::vector<G4HnInformation*> fHnVector;
137 std::shared_ptr<G4VFileManager> fFileManager { nullptr };
138
139 // Messenger
140 std::unique_ptr<G4HnMessenger> fMessenger;
141};
142
144{ return G4int(fHnVector.size()); }
145
147{ return fNofActiveObjects; }
148
150{ return fHnType; }
151
152inline const std::vector<G4HnInformation*>& G4HnManager::GetHnVector() const
153{ return fHnVector; }
154
155inline void G4HnManager::SetFileManager(std::shared_ptr<G4VFileManager> fileManager)
156{
157 fFileManager = std::move(fileManager);
158}
159
160#endif
161
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4HnDimensionInformation * GetHnDimensionInformation(G4int id, G4int dimension, std::string_view functionName, G4bool warn=true) const
Definition: G4HnManager.cc:157
void ClearData()
Definition: G4HnManager.cc:132
G4int GetNofActiveHns() const
Definition: G4HnManager.hh:146
G4bool GetPlotting(G4int id) const
Definition: G4HnManager.cc:339
G4bool SetAxisIsLog(unsigned int idim, G4int id, G4bool isLogAxis)
Definition: G4HnManager.cc:278
void SetActivation(G4bool activation)
Definition: G4HnManager.cc:204
G4int GetNofHns() const
Definition: G4HnManager.hh:143
void SetFileManager(std::shared_ptr< G4VFileManager > fileManager)
Definition: G4HnManager.hh:155
G4String GetFileName(G4int id) const
Definition: G4HnManager.cc:349
G4String GetName(G4int id) const
Definition: G4HnManager.cc:289
G4bool IsAscii() const
Definition: G4HnManager.cc:174
~G4HnManager() override
Definition: G4HnManager.cc:48
G4bool IsPlotting() const
Definition: G4HnManager.cc:180
void SetFileName(G4int id, const G4String &fileName)
Definition: G4HnManager.cc:258
G4bool GetActivation(G4int id) const
Definition: G4HnManager.cc:319
const std::vector< G4HnInformation * > & GetHnVector() const
Definition: G4HnManager.hh:152
G4bool GetAxisIsLog(unsigned int idim, G4int id) const
Definition: G4HnManager.cc:309
G4double GetUnit(unsigned int idim, G4int id) const
Definition: G4HnManager.cc:299
G4bool IsActive() const
Definition: G4HnManager.cc:168
void SetAscii(G4int id, G4bool ascii)
Definition: G4HnManager.cc:218
G4String GetHnType() const
Definition: G4HnManager.hh:149
void SetPlotting(G4int id, G4bool plotting)
Definition: G4HnManager.cc:238
G4HnInformation * GetHnInformation(G4int id, std::string_view functionName, G4bool warn=true) const
Definition: G4HnManager.cc:142
G4HnManager()=delete
G4bool GetAscii(G4int id) const
Definition: G4HnManager.cc:329
G4bool IsFileName() const
Definition: G4HnManager.cc:186
G4HnInformation * AddHnInformation(const G4String &name, G4int nofDimensions)
Definition: G4HnManager.cc:122