Geant4 11.1.1
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 // Set methods
117 void AddDimension(const G4HnDimensionInformation& hnDimensionInformation);
118 void SetDimension(G4int dimension, const G4HnDimensionInformation& hnDimensionInformation);
119
120 void SetIsLogAxis(G4int axis, G4bool isLog);
121 void SetActivation(G4bool activation);
122 void SetAscii(G4bool ascii);
123 void SetPlotting(G4bool plotting);
124 void SetFileName(const G4String& fileName);
125
126 // Get methods
127 G4String GetName() const;
130 G4bool GetIsLogAxis(G4int axis) const;
131 G4bool GetActivation() const;
132 G4bool GetAscii() const;
133 G4bool GetPlotting() const;
134 G4String GetFileName() const;
135
136 private:
137 // Data members
138 G4String fName;
139 std::vector<G4HnDimensionInformation> fHnDimensionInformations;
140 std::vector<G4bool> fIsLogAxis { false, false, false };
141 G4bool fActivation { true };
142 G4bool fAscii { false };
143 G4bool fPlotting { false };
144 G4String fFileName;
145};
146
147namespace G4Analysis
148{
149
150// Apply Hn information
151void Update(G4double& value, const G4HnDimensionInformation& hnInfo);
152void UpdateValues(G4HnDimension& bins, const G4HnDimensionInformation& hnInfo);
153void Update(G4HnDimension& bins, const G4HnDimensionInformation& hnInfo);
154void UpdateTitle(G4String& title, const G4HnDimensionInformation& hnInfo);
155
156// Paremeters check
158G4bool CheckDimension(unsigned int idim,
159 const G4HnDimension& dimension, const G4HnDimensionInformation& info);
160
161template <unsigned int DIM>
163 const std::array<G4HnDimension, DIM>& bins,
164 const std::array<G4HnDimensionInformation, DIM>& hnInfo,
165 G4bool isProfile = false);
166}
167
168// inline functions
169
171 const G4HnDimensionInformation& hnDimensionInformation)
172{ fHnDimensionInformations.push_back(hnDimensionInformation); }
173
175 G4int dimension, const G4HnDimensionInformation& hnDimensionInformation)
176{
177 auto info = GetHnDimensionInformation(dimension);
178 (*info) = hnDimensionInformation;
179}
180
182{ fIsLogAxis[axis] = isLog; }
183
185{ fActivation = activation; }
186
188{ fAscii = ascii; }
189
191{ fPlotting = plotting; }
192
193inline void G4HnInformation::SetFileName(const G4String& fileName)
194{ fFileName = fileName; }
195
197{ return fName; }
198
200{ return &(fHnDimensionInformations[dimension]); }
201
203{ return fHnDimensionInformations[dimension]; }
204
206{ return fIsLogAxis[axis]; }
207
209{ return fActivation; }
210
212{ return fAscii; }
213
215{ return fPlotting; }
216
218{ return fFileName; }
219
220template <unsigned int DIM>
222 const std::array<G4HnDimension, DIM>& bins,
223 const std::array<G4HnDimensionInformation, DIM>& hnInfo,
224 G4bool isProfile)
225{
226 G4bool result = true;
227
228 // Check bins parameters
229 // (the last dimension has special meaninh for profiles)
230 auto dimToCheck = (isProfile) ? DIM -1 : DIM ;
231 for (unsigned int idim = 0; idim < dimToCheck; ++idim) {
232 result &= CheckDimension(idim, bins[idim], hnInfo[idim]);
233 }
234
235 // Check profile min/max value
236 if (isProfile) {
237 result &= CheckMinMax(bins[DIM-1].fMinValue, bins[DIM-1].fMaxValue);
238 }
239
240 return result;
241}
242
243#endif
G4BinScheme
Definition: G4BinScheme.hh:39
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)
G4bool GetPlotting() const
G4bool GetActivation() const
G4bool GetAscii() const
G4String GetName() const
void SetIsLogAxis(G4int axis, G4bool isLog)
G4HnDimensionInformation * GetHnDimensionInformation(G4int dimension)
void SetActivation(G4bool activation)
G4String GetFileName() const
void SetFileName(const G4String &fileName)
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)
G4double fMaxValue
std::vector< G4double > fEdges
G4HnDimension(const std::vector< G4double > &edges)
G4double fMinValue
void Print() const
G4HnDimension(const G4HnDimension &rhs)=default
G4HnDimension()=default