Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4HnInformation.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// Data class for the added Hn/Pn information (not available in g4tools).
28//
29// Author: Ivana Hrivnacova, 04/07/2012 ([email protected])
30
31#ifndef G4HnInformation_h
32#define G4HnInformation_h 1
33
35#include "G4BinScheme.hh"
36#include "G4Fcn.hh"
37#include "globals.hh"
38
39#include <utility>
40#include <vector>
41
42// The histogram input parameters per dimension
44{
46 G4int nbins,
47 G4double minValue,
48 G4double maxValue)
49 : fNBins(nbins),
50 fMinValue(minValue),
51 fMaxValue(maxValue)
52 {
53 fEdges.clear();
54 }
55
56 G4HnDimension(const std::vector<G4double>& edges)
57 : fNBins(0),
58 fMinValue(0.),
59 fMaxValue(0.),
60 fEdges(edges)
61 {}
62
63 G4HnDimension() = default;
64 G4HnDimension(const G4HnDimension& rhs) = default;
65 G4HnDimension& operator=(const G4HnDimension& rhs) = default;
66
67 void Print() const;
68
72 std::vector<G4double> fEdges;
73};
74
75// The additional histogram information per dimension
77{
79 G4String unitName,
80 G4String fcnName,
81 G4String binSchemeName = "linear")
82 : fUnitName(std::move(unitName)),
83 fFcnName(std::move(fcnName)),
84 fBinSchemeName(std::move(binSchemeName)),
85 fUnit(G4Analysis::GetUnitValue(fUnitName)),
86 fFcn(G4Analysis::GetFunction(fFcnName)),
88 {}
89
91 : G4HnDimensionInformation("none", "none", "linear") {}
94
95 void Print() const;
96
103};
104
105// The additional histogram information
107{
108 public:
109 G4HnInformation(G4String name, G4int nofDimensions)
110 : fName(std::move(name))
111 { fHnDimensionInformations.reserve(nofDimensions); }
112
113 // Deleted default constructor
114 G4HnInformation() = delete;
115
116 // Clear all data
117 void Update(const G4HnInformation& other) {
118 // Update all information except name and fHnDimensionInformations
119 for (G4int i = 0; i < (G4int)fHnDimensionInformations.size(); ++i) {
120 SetIsLogAxis(i, other.GetIsLogAxis(i));
121 }
122 fActivation = other.GetActivation();
123 fAscii = other.GetAscii();
124 fPlotting = other.GetPlotting();
125 fFileName = other.GetFileName();
126 }
127
128 // Set methods
129 void AddDimension(const G4HnDimensionInformation& hnDimensionInformation);
130 void SetDimension(G4int dimension, const G4HnDimensionInformation& hnDimensionInformation);
131
132 void SetIsLogAxis(G4int axis, G4bool isLog);
133 void SetActivation(G4bool activation);
134 void SetAscii(G4bool ascii);
135 void SetPlotting(G4bool plotting);
136 void SetDeleted(G4bool deleted, G4bool keepSetting);
137 void SetFileName(const G4String& fileName);
138
139 // Get methods
140 G4String GetName() const;
143 G4bool GetIsLogAxis(G4int axis) const;
144 G4bool GetActivation() const;
145 G4bool GetAscii() const;
146 G4bool GetPlotting() const;
147 G4bool GetDeleted() const;
148 std::pair<G4bool, G4bool> GetDeletedPair() const;
149 G4String GetFileName() const;
150
151 private:
152 // Data members
153 G4String fName;
154 std::vector<G4HnDimensionInformation> fHnDimensionInformations;
155 std::vector<G4bool> fIsLogAxis { false, false, false };
156 G4bool fActivation { true };
157 G4bool fAscii { false };
158 G4bool fPlotting { false };
159 std::pair<G4bool, G4bool> fDeleted { false, false };
160 G4String fFileName;
161};
162
163namespace G4Analysis
164{
165
166// Apply Hn information
167void Update(G4double& value, const G4HnDimensionInformation& hnInfo);
168void UpdateValues(G4HnDimension& bins, const G4HnDimensionInformation& hnInfo);
169void Update(G4HnDimension& bins, const G4HnDimensionInformation& hnInfo);
170void UpdateTitle(G4String& title, const G4HnDimensionInformation& hnInfo);
171
172// Paremeters check
174G4bool CheckDimension(unsigned int idim,
175 const G4HnDimension& dimension, const G4HnDimensionInformation& info);
176
177template <unsigned int DIM>
179 const std::array<G4HnDimension, DIM>& bins,
180 const std::array<G4HnDimensionInformation, DIM>& hnInfo,
181 G4bool isProfile = false);
182}
183
184// inline functions
185
187 const G4HnDimensionInformation& hnDimensionInformation)
188{ fHnDimensionInformations.push_back(hnDimensionInformation); }
189
191 G4int dimension, const G4HnDimensionInformation& hnDimensionInformation)
192{
193 auto info = GetHnDimensionInformation(dimension);
194 (*info) = hnDimensionInformation;
195}
196
198{ fIsLogAxis[axis] = isLog; }
199
201{ fActivation = activation; }
202
204{ fAscii = ascii; }
205
207{ fPlotting = plotting; }
208
209inline void G4HnInformation::SetDeleted(G4bool deleted, G4bool keepSetting)
210{ fDeleted = std::make_pair(deleted, keepSetting); }
211
212inline void G4HnInformation::SetFileName(const G4String& fileName)
213{ fFileName = fileName; }
214
216{ return fName; }
217
219{ return &(fHnDimensionInformations[dimension]); }
220
222{ return fHnDimensionInformations[dimension]; }
223
225{ return fIsLogAxis[axis]; }
226
228{ return fActivation; }
229
231{ return fAscii; }
232
234{ return fPlotting; }
235
237{ return fDeleted.first; }
238
239inline std::pair<G4bool, G4bool> G4HnInformation::GetDeletedPair() const
240{ return fDeleted; }
241
243{ return fFileName; }
244
245template <unsigned int DIM>
247 const std::array<G4HnDimension, DIM>& bins,
248 const std::array<G4HnDimensionInformation, DIM>& hnInfo,
249 G4bool isProfile)
250{
251 G4bool result = true;
252
253 // Check bins parameters
254 // (the last dimension has special meaninh for profiles)
255 auto dimToCheck = (isProfile) ? DIM -1 : DIM ;
256 for (unsigned int idim = 0; idim < dimToCheck; ++idim) {
257 result &= CheckDimension(idim, bins[idim], hnInfo[idim]);
258 }
259
260 // Check profile min/max value
261 if (isProfile) {
262 result &= CheckMinMax(bins[DIM-1].fMinValue, bins[DIM-1].fMaxValue);
263 }
264
265 return result;
266}
267
268#endif
G4BinScheme
G4double(*)(G4double) G4Fcn
Definition G4Fcn.hh:35
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
void SetAscii(G4bool ascii)
void SetPlotting(G4bool plotting)
G4HnInformation(G4String name, G4int nofDimensions)
G4bool GetIsLogAxis(G4int axis) const
G4HnInformation()=delete
void SetDimension(G4int dimension, const G4HnDimensionInformation &hnDimensionInformation)
void AddDimension(const G4HnDimensionInformation &hnDimensionInformation)
void SetDeleted(G4bool deleted, G4bool keepSetting)
G4bool GetPlotting() const
G4bool GetActivation() const
G4bool GetAscii() const
G4String GetName() const
void SetIsLogAxis(G4int axis, G4bool isLog)
void Update(const G4HnInformation &other)
G4bool GetDeleted() const
G4HnDimensionInformation * GetHnDimensionInformation(G4int dimension)
void SetActivation(G4bool activation)
G4String GetFileName() const
void SetFileName(const G4String &fileName)
std::pair< G4bool, G4bool > GetDeletedPair() const
G4bool CheckDimension(unsigned int idim, const G4HnDimension &dimension, const G4HnDimensionInformation &info)
void UpdateTitle(G4String &title, const G4HnDimensionInformation &hnInfo)
void Update(G4double &value, const G4HnDimensionInformation &hnInfo)
void UpdateValues(G4HnDimension &bins, const G4HnDimensionInformation &hnInfo)
G4bool CheckDimensions(const std::array< G4HnDimension, DIM > &bins, const std::array< G4HnDimensionInformation, DIM > &hnInfo, G4bool isProfile=false)
G4bool CheckMinMax(G4double min, G4double max)
G4HnDimensionInformation(const G4HnDimensionInformation &rhs)=default
G4HnDimensionInformation & operator=(const G4HnDimensionInformation &rhs)=default
G4HnDimensionInformation(G4String unitName, G4String fcnName, G4String binSchemeName="linear")
G4HnDimension & operator=(const G4HnDimension &rhs)=default
G4HnDimension(G4int nbins, G4double minValue, G4double maxValue)
std::vector< G4double > fEdges
G4HnDimension(const std::vector< G4double > &edges)
void Print() const
G4HnDimension(const G4HnDimension &rhs)=default
G4HnDimension()=default