Geant4 11.3.0
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 : fEdges(edges) {}
58 G4HnDimension() = default;
59 G4HnDimension(const G4HnDimension& rhs) = default;
60 G4HnDimension& operator=(const G4HnDimension& rhs) = default;
61
62 void Print() const;
63
67 std::vector<G4double> fEdges;
68};
69
70// The additional histogram information per dimension
72{
74 G4String unitName,
75 G4String fcnName,
76 G4String binSchemeName = "linear")
77 : fUnitName(std::move(unitName)),
78 fFcnName(std::move(fcnName)),
79 fBinSchemeName(std::move(binSchemeName)),
80 fUnit(G4Analysis::GetUnitValue(fUnitName)),
81 fFcn(G4Analysis::GetFunction(fFcnName)),
83 {}
84
86 : G4HnDimensionInformation("none", "none", "linear") {}
89
90 void Print() const;
91
98};
99
100// The additional histogram information
102{
103 public:
104 G4HnInformation(G4String name, G4int nofDimensions)
105 : fName(std::move(name))
106 { fHnDimensionInformations.reserve(nofDimensions); }
107
108 // Deleted default constructor
109 G4HnInformation() = delete;
110
111 // Clear all data
112 void Update(const G4HnInformation& other) {
113 // Update all information except name and fHnDimensionInformations
114 for (G4int i = 0; i < (G4int)fHnDimensionInformations.size(); ++i) {
115 SetIsLogAxis(i, other.GetIsLogAxis(i));
116 }
117 fActivation = other.GetActivation();
118 fAscii = other.GetAscii();
119 fPlotting = other.GetPlotting();
120 fFileName = other.GetFileName();
121 }
122
123 // Set methods
124 void AddDimension(const G4HnDimensionInformation& hnDimensionInformation);
125 void SetDimension(G4int dimension, const G4HnDimensionInformation& hnDimensionInformation);
126
127 void SetIsLogAxis(G4int axis, G4bool isLog);
128 void SetActivation(G4bool activation);
129 void SetAscii(G4bool ascii);
130 void SetPlotting(G4bool plotting);
131 void SetDeleted(G4bool deleted, G4bool keepSetting);
132 void SetFileName(const G4String& fileName);
133
134 // Get methods
135 G4String GetName() const;
138 G4bool GetIsLogAxis(G4int axis) const;
139 G4bool GetActivation() const;
140 G4bool GetAscii() const;
141 G4bool GetPlotting() const;
142 G4bool GetDeleted() const;
143 std::pair<G4bool, G4bool> GetDeletedPair() const;
144 G4String GetFileName() const;
145
146 private:
147 // Data members
148 G4String fName;
149 std::vector<G4HnDimensionInformation> fHnDimensionInformations;
150 std::vector<G4bool> fIsLogAxis { false, false, false };
151 G4bool fActivation { true };
152 G4bool fAscii { false };
153 G4bool fPlotting { false };
154 std::pair<G4bool, G4bool> fDeleted { false, false };
155 G4String fFileName;
156};
157
158namespace G4Analysis
159{
160
161// Apply Hn information
162void Update(G4double& value, const G4HnDimensionInformation& hnInfo);
163void UpdateValues(G4HnDimension& bins, const G4HnDimensionInformation& hnInfo);
164void Update(G4HnDimension& bins, const G4HnDimensionInformation& hnInfo);
165void UpdateTitle(G4String& title, const G4HnDimensionInformation& hnInfo);
166
167// Paremeters check
169G4bool CheckDimension(unsigned int idim,
170 const G4HnDimension& dimension, const G4HnDimensionInformation& info);
171
172template <unsigned int DIM>
174 const std::array<G4HnDimension, DIM>& bins,
175 const std::array<G4HnDimensionInformation, DIM>& hnInfo,
176 G4bool isProfile = false);
177}
178
179// inline functions
180
182 const G4HnDimensionInformation& hnDimensionInformation)
183{ fHnDimensionInformations.push_back(hnDimensionInformation); }
184
186 G4int dimension, const G4HnDimensionInformation& hnDimensionInformation)
187{
188 auto info = GetHnDimensionInformation(dimension);
189 (*info) = hnDimensionInformation;
190}
191
193{ fIsLogAxis[axis] = isLog; }
194
196{ fActivation = activation; }
197
199{ fAscii = ascii; }
200
202{ fPlotting = plotting; }
203
204inline void G4HnInformation::SetDeleted(G4bool deleted, G4bool keepSetting)
205{ fDeleted = std::make_pair(deleted, keepSetting); }
206
207inline void G4HnInformation::SetFileName(const G4String& fileName)
208{ fFileName = fileName; }
209
211{ return fName; }
212
214{ return &(fHnDimensionInformations[dimension]); }
215
217{ return fHnDimensionInformations[dimension]; }
218
220{ return fIsLogAxis[axis]; }
221
223{ return fActivation; }
224
226{ return fAscii; }
227
229{ return fPlotting; }
230
232{ return fDeleted.first; }
233
234inline std::pair<G4bool, G4bool> G4HnInformation::GetDeletedPair() const
235{ return fDeleted; }
236
238{ return fFileName; }
239
240template <unsigned int DIM>
242 const std::array<G4HnDimension, DIM>& bins,
243 const std::array<G4HnDimensionInformation, DIM>& hnInfo,
244 G4bool isProfile)
245{
246 G4bool result = true;
247
248 // Check bins parameters
249 // (the last dimension has special meaninh for profiles)
250 auto dimToCheck = (isProfile) ? DIM -1 : DIM ;
251 for (unsigned int idim = 0; idim < dimToCheck; ++idim) {
252 result &= CheckDimension(idim, bins[idim], hnInfo[idim]);
253 }
254
255 // Check profile min/max value
256 if (isProfile) {
257 result &= CheckMinMax(bins[DIM-1].fMinValue, bins[DIM-1].fMaxValue);
258 }
259
260 return result;
261}
262
263#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