Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ExtendedPhysicsVector.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// G4ExtendedPhysicsVector
27//
28// Class description:
29//
30// A data scructure which includes G4PhysicsVector and also data on
31// partial x-sections
32//
33// Author: V.Ivanchenko 09.09.2025
34//
35// --------------------------------------------------------------------
36#ifndef G4ExtendedPhysicsVector_hh
37#define G4ExtendedPhysicsVector_hh 1
38
39#include <vector>
40
41#include "globals.hh"
42#include "G4PhysicsVector.hh"
43
45{
46public:
47
48 explicit G4ExtendedPhysicsVector(G4PhysicsVector*, G4int nxsec = 0);
50
51 // Copy constructor and assignment operator
54
55 // not used operators
58 G4bool operator==(const G4ExtendedPhysicsVector& right) const = delete;
59
60 // get G4PhysicsVector with total cross section
61 inline const G4PhysicsVector* GetPhysicsVector() const;
62
63 // Get the value from the total x-section using interpolation defined
64 // in the G4PhysicsVector object. Consumer code gets changed
65 // index and may reuse it for the next call to save CPU for bin location.
66 inline G4double Value(const G4double energy, std::size_t& lastidx) const;
67
68 // Get the cross-section/energy-loss value corresponding to the
69 // given energy using log-log interpolation. Consumer code gets changed
70 // index and may reuse it for the next call to save CPU for bin location.
71 // Spline is not used in this method.
72 G4double LogLogValue(const G4double energy, std::size_t& lastidx) const;
73
74 // This method may be applied only once.
75 // Force length of data using std::vector::resize() with the
76 // the default value 0; partial cross section vector is resized
77 // only if the number of partial x-sections is above zero.
78 void SetDataLength(G4int dlength);
79
80 // Filled partial cross sections by energy index (0 <= idx < numberOfNodes)
81 // It is assumed that the array y does not have negative values.
82 void PutPartialXSData(const std::size_t idx, const G4double* y);
83
84 // Sample partial reaction channel for given energy, rand - uniform
85 // random number, lastidx is the cache allowing to reduce CPU for energy
86 // bin location. Data are stored as float but computations are in double.
87 G4int SampleReactionChannel(const G4double energy, const G4double rand,
88 std::size_t& lastidx) const;
89
90 // randomly select partial cross section using Log-Log interpolation
91 G4int SampleReactionChannelLogLog(const G4double energy, const G4double rand,
92 std::size_t& lastidx) const;
93
94 // Print data
95 void DumpValues(G4double unitE = 1.0, G4double unitV = 1.0) const;
96
97private:
98
99 G4int verboseLevel = 0;
100 G4int nPartialXS = 0;
101 std::size_t idxmax = 0;
102 std::size_t numberOfNodes = 0;
103
104 // The partial cumulative x-sections normalized to the sum
105 std::vector<std::vector<G4float>* >* dataPartialXS = nullptr;
106 G4PhysicsVector* totalData = nullptr;
107};
108
110{
111 return totalData;
112}
113
114inline G4double G4ExtendedPhysicsVector::Value(const G4double e, std::size_t& idx) const
115{
116 return totalData->Value(e, idx);
117}
118
119#endif
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
G4int SampleReactionChannelLogLog(const G4double energy, const G4double rand, std::size_t &lastidx) const
void PutPartialXSData(const std::size_t idx, const G4double *y)
void DumpValues(G4double unitE=1.0, G4double unitV=1.0) const
G4bool operator==(const G4ExtendedPhysicsVector &right) const =delete
G4ExtendedPhysicsVector(const G4ExtendedPhysicsVector &)=default
G4int SampleReactionChannel(const G4double energy, const G4double rand, std::size_t &lastidx) const
G4ExtendedPhysicsVector & operator=(const G4ExtendedPhysicsVector &)=default
G4ExtendedPhysicsVector(const G4ExtendedPhysicsVector &&)=delete
G4double LogLogValue(const G4double energy, std::size_t &lastidx) const
G4ExtendedPhysicsVector(G4PhysicsVector *, G4int nxsec=0)
G4double Value(const G4double energy, std::size_t &lastidx) const
const G4PhysicsVector * GetPhysicsVector() const
G4ExtendedPhysicsVector & operator=(const G4ExtendedPhysicsVector &&)=delete